# Maintainer: Zoltan Gyarmati <zgyarmati@zgyarmati.de>

_realname=dwarfstack
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2.1
pkgrel=2
pkgdesc="Provides stacktrace with source file/line information (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://github.com/ssbssa/dwarfstack"
license=('LGPL')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-binutils")
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/ssbssa/${_realname}/archive/${pkgver}.tar.gz")
sha256sums=('c9dcb64c23e714b5ea1a87f4723c2ac6cd99d25fb0805b56e4403edff11c4d0f')

build() {
  [[ -d "${srcdir}/build-${MSYSTEM}" ]] && rm -rf "${srcdir}/build-${MSYSTEM}"
  cp -r "${srcdir}/${_realname}-${pkgver}" "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  make CC=${CC}
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  make install PREFIX="${pkgdir}${MINGW_PREFIX}"
  install -D -m644 "${srcdir}/${_realname}-${pkgver}/LICENSE.txt" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
